<?php

$em_version = get_option('em_version');

function em_echo_message($message) {
	echo "<p>" . $message . "<p>";
}

$event_count = $wpdb->get_var("SELECT count(*) from $em_event_table");

if ($event_count > 0 && $em_version < 101) {
	$wpdb->query("ALTER TABLE $em_question_table ADD `required` ENUM( 'Y', 'N' ) NOT NULL DEFAULT 'N'");
	$wpdb->query("ALTER TABLE $em_event_table ADD `login_required` ENUM( 'Y', 'N' ) NOT NULL DEFAULT 'N' AFTER `phone`");

	if (!mysql_error()) {
		em_echo_message("Upgrade to 1.0.1 successful!");
	}
}

update_option('em_version', "102");
